#include <stdio.h>
#include <stdarg.h>
#include <string.h>

// 入参：/a%d/ball, int    or    /s0x%llx/ball, U64                             输出：/a2/ball  or   /s0x1234/ball
// 入参：/a%d/b%d, int, int    or    /s0x%llx/b%d, U64, int                     输出：/a2/b3    or   /s0x1234/b3
// 入参：/a%d/b%d/c%d, int, int, int    or   /s0x%llx/b%d/c%d, U64, int, int    输出：/a2/b3/c4    or   /s0x1234/b3/c4

#define TRUE 1
void myPrintf(char *format, int d, ...)
{
    va_list list;
    va_start(list, d);

    // 代码可优化，此处仅做示例
    char buffer[64];
    if (TRUE) {
        char temp[64] = "a%d";
        strcat(temp, format);
        sprintf(buffer, temp, d, va_arg(list, int));
        printf("buffer===%s\n ", buffer);
    } else {
        char temp[64] = "sas0x%d";
        strcat(temp, format);
        sprintf(buffer, temp, d, va_arg(list, int));
        printf("buffer===%s\n ", buffer);
    }

    va_end(list);
}
int main()
{
    myPrintf("/ball", 2);
    myPrintf("/b%d", 2, 9);
    return 0;
}
